using System;
using System.Windows;
using System.Windows.Media.Animation;
namespace Microsoft.Phone.Controls.Maps.Core
{
	internal static class PhysicsHelper
	{
		internal const float FrictionCoefficient = 500f;
		internal static IEasingFunction GetEasingFunction()
		{
			QuadraticEase quadraticEase = new QuadraticEase();
			quadraticEase.set_EasingMode(0);
			return quadraticEase;
		}
		internal static Point GetStopPoint(Point velocity, Point initialPosition)
		{
			double stopTime = PhysicsHelper.GetStopTime(velocity);
			double num = Math.Sqrt(velocity.get_X() * velocity.get_X() + velocity.get_Y() * velocity.get_Y());
			Point point = new Point(500.0 * velocity.get_X() / num, 500.0 * velocity.get_Y() / num);
			return new Point(initialPosition.get_X() + stopTime * velocity.get_X() - point.get_X() * stopTime * stopTime / 2.0, initialPosition.get_Y() + stopTime * velocity.get_Y() - point.get_Y() * stopTime * stopTime / 2.0);
		}
		internal static double GetStopTime(Point velocity)
		{
			return Math.Sqrt(velocity.get_X() * velocity.get_X() + velocity.get_Y() * velocity.get_Y()) / 500.0;
		}
		internal static int GetAngleFromVelocity(Point velocity)
		{
			double x = velocity.get_X();
			double y = velocity.get_Y();
			double num;
			if (x == 0.0 && y == 0.0)
			{
				num = 0.0;
			}
			else
			{
				if (x == 0.0)
				{
					if (y > 0.0)
					{
						num = 90.0;
					}
					else
					{
						num = 270.0;
					}
				}
				else
				{
					if (y == 0.0)
					{
						if (x > 0.0)
						{
							num = 0.0;
						}
						else
						{
							num = 180.0;
						}
					}
					else
					{
						num = PhysicsHelper.RadianToDegree(Math.Atan2(y, x));
					}
				}
			}
			return (int)num;
		}
		internal static double DegreeToRadian(double angle)
		{
			return 3.1415926535897931 * angle / 180.0;
		}
		internal static double RadianToDegree(double angle)
		{
			return angle * 57.295779513082323;
		}
		internal static bool ExceedsThreshold(Point delta, long threshold)
		{
			return Math.Abs(delta.get_X()) > (double)threshold || Math.Abs(delta.get_Y()) > (double)threshold;
		}
		internal static bool ExceedsThreshold(TimeSpan delta, long threshold)
		{
			return delta > TimeSpan.FromMilliseconds((double)threshold);
		}
		internal static Point Delta(Point p1, Point p2)
		{
			return new Point(p1.get_X() - p2.get_X(), p1.get_Y() - p2.get_Y());
		}
		internal static Point Center(Point p1, Point p2)
		{
			return new Point((p1.get_X() + p2.get_X()) / 2.0, (p1.get_Y() + p2.get_Y()) / 2.0);
		}
		internal static double Distance(Point p1, Point p2)
		{
			Point point = PhysicsHelper.Delta(p1, p2);
			return Math.Sqrt(point.get_X() * point.get_X() + point.get_Y() * point.get_Y());
		}
		internal static Point NextPoint(Point initial, Point velocity, TimeSpan duration)
		{
			return new Point(initial.get_X() + velocity.get_X() * duration.get_TotalSeconds(), initial.get_Y() + velocity.get_Y() * duration.get_TotalSeconds());
		}
	}
}
